package net.huashitong.ssydt.security.utils;


import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 返回JSON基本结构
 *
 * @author huiyang.yu
 */
public class ResultUtils {

    public static Result<String> getResults(String code) {
        return getResults(code, "");
    }

    public static Result<String> getResults(String code, String message) {
        return getResults(code, message, "");
    }

    public static <T extends Serializable> Result<T> getResults(String code, String message, T results) {
        Result<T> result = new Result<T>();
        result.setCode(code);
        result.setMessage(message);
        result.setResults(results);
        return result;
    }

    public static Result<String> getSuccessResults() {
        return getSuccessResults("");
    }

    public static <T extends Serializable> Result<T> getSuccessResults(T results) {
        return getResults(Result.Status.SUCCESS, "操作成功", results);
    }

    public static <T extends Serializable> Result<ArrayList<T>> getSuccessResultList(List<T> list) {
        return getSuccessResults((ArrayList<T>) list);
    }

    private ResultUtils() {
    }
}
